// Tierless
// Copyright © 2010 Alphora
// This file is licensed under a modified BSD-license (see tierless_license.txt).

using System;

using Tierless.Framework.Entities;

namespace Tierless.Framework.Data
{
	/// <summary>
	/// Represents a change to an entity.
	/// </summary>
	public class EntityChange
	{
		/// <summary>
		/// Constructs a new instance of the EntityChange class.
		/// </summary>
		/// <param name="entity">The entity that was changed.</param>
		/// <param name="isTemporalUpdate">Indicates that the change affects the lifetime of the entity.</param>
		/// <param name="columns">The list of columns that were changed.</param>
		public EntityChange(Entity entity, bool isTemporalUpdate, params string[] columns)
		{
			if (entity == null)
				throw new ArgumentException("Entity must be provided for an EntityChange");

			Entity = entity;
			IsTemporalUpdate = isTemporalUpdate;
			Columns = columns ?? new string[0];
		}

		/// <summary>
		/// Gets the entity that was changed.
		/// </summary>
		public Entity Entity { get; private set; }

		/// <summary>
		/// Gets whether or not the change affects the lifetime of the entity.
		/// </summary>
		public bool IsTemporalUpdate { get; private set; }

		/// <summary>
		/// Gets the list of columns that were changed.
		/// </summary>
		public string[] Columns { get; private set; }
	}
}